package com.czk.springboot.reactive.reactor.flux;

import reactor.core.publisher.Flux;

import java.time.Duration;

public class FluxDemo2 {

    public static void main(String[] args) throws InterruptedException {

        Flux<Integer> flux = Flux.range(0, 10) // 0到9
                .delayElements(Duration.ofSeconds(1))
                .doOnComplete(() -> {
                    System.out.println("流结束了=======");
                })
                .doOnCancel(() -> {
                    System.out.println("流被取消了");
                }).
                doOnNext(e->{
                    System.out.println("流的下一个元素到了====");
                });

        flux.subscribe(System.out::println);

      //  TimeUnit.SECONDS.sleep(6);

        while (true) {
        }
    }

}
